package com.example.demo;

import java.util.ArrayList;
import java.util.List;

public class TestFor {

    public static void main(String[] args) {
        List<User> userList = new ArrayList<>();
        User zy = new User("赵云",12);
        userList.add(zy);
        User gy = new User("关羽",13);
        userList.add(gy);
        User zf = new User("张飞",14);
        userList.add(zf);
        int index = 0;
        for(User user:userList){
            if(user.getAge()==12){
                userList.add(index+1,new User("刘备",15));
                break;
            }
            System.out.println(user);
            index ++ ;
        }
        System.out.println(userList);
    }
}
